#include "stdafx.h"

#include <MyFC/Widget.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

namespace My {

Widget::Widget() :
	m_Visible(true), 
	m_Enabled(true),
	m_Bounds(0, 0, 0, 0), 
	m_pFont(0)
{
}

const CFont * Widget::Font() const
{ 
	return m_pFont != 0 ? m_pFont : Control::Font(); 
}

void Widget::SetBounds(const CRect & rect)
{
	CRect r(rect);
	CheckBounds(r);
	if (m_Bounds != r)
	{
		bool bResized = (r.Size() != m_Bounds.Size()) != 0;
		Invalidate();
		m_Bounds = r;
		UpdateBounds();
		if (bResized)
			HandleResize(m_Bounds.Width(), m_Bounds.Height());
	}
}

void Widget::SetVisible(bool on)
{
	if (on != m_Visible)
	{
		m_Visible = on;
		HandleVisible(m_Visible);
		if (Parent() != 0)
			Parent()->Invalidate();
	}
}

void Widget::SetEnabled(bool on)
{
	if (on != m_Enabled)
	{
		m_Enabled = on;
		HandleEnable(m_Enabled);
		Invalidate();
	}
}

void Widget::SetFont(CFont * pFont)
{
	if (pFont != m_pFont) 
	{
		m_pFont = pFont;
		Invalidate();
	}
}


} // My
